﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace LabMS.Web.LabPersonnel
{
    public partial class PositionLogPreview : Base.BasePage
    {
        public int ID = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            strPagePrivilege.Add("GWRZGL");
            strPageUserType.Add("mana");
            strPageUserType.Add("teacher");
            if (Request.QueryString["id"] == null)
            {
                Common.JShelper.JSAlert(Page, "err", "参数错误!");
                return;
            }
            if (!int.TryParse(Request.QueryString["ID"], out ID))
            {
                Common.JShelper.JSAlert(Page, "err", "参数错误!");
                return;
            }
            if (!IsPostBack)
            {
                BindData(ID);
            }
        }

        //绑定数据
        private void BindData(int ID)
        {
            LabMS.BLL.PositionLog pLog = new LabMS.BLL.PositionLog();
            LabMS.Model.PositionLog pLogInfo = new LabMS.Model.PositionLog();

            pLogInfo = pLog.GetModel(ID);
            PLogTeacherName.Text = pLogInfo.PLog_TeacherName;
            PLogTime.Text = pLogInfo.PLog_Time.Value.ToShortDateString();
            PLogEquipment.Text = pLogInfo.PLog_Equipment;
            PLogLabIntro.Text = pLogInfo.PLog_LabIntro;
            PLogOther.Text = pLogInfo.PLog_Other;
        }

        //删除
        protected void Delete_OnClick(object sender, EventArgs e)
        {
            LabMS.BLL.PositionLog positionlog = new LabMS.BLL.PositionLog();
            try
            {
                positionlog.Delete(ID);
                LabMS.Common.JShelper.JSAlertAndRedirect(Page, "deleteSuccess", "删除成功!", "ListPositionLog.aspx");
            }
            catch
            {
                LabMS.Common.JShelper.JSAlert(Page, "err", "删除失败!");
            }
        }
    }
}
